package com.ikas.ai.server.module;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.ikas.ai.consts.MachineAndWorkConditionConst;
import com.ikas.ai.handle.JsonResult;
import com.ikas.ai.server.common.parser.JSONWorkFlowParser;
import com.ikas.ai.server.common.parser.model.FlowMetaData;
import com.ikas.ai.server.common.parser.model.StepDetailMetaData;
import com.ikas.ai.server.common.parser.model.StepMetaData;
import com.ikas.ai.server.common.parser.model.WorkFlowMetaData;
import com.ikas.ai.server.error.BusinessException;
import com.ikas.ai.server.module.condition.model.WorkConditionFlow;
import com.ikas.ai.server.module.condition.model.WorkConditionStep;
import com.ikas.ai.server.module.condition.model.WorkConditionStepDetail;
import com.ikas.ai.server.module.condition.service.WorkConditionFlowService;
import com.ikas.ai.server.module.condition.service.WorkConditionStepDetailService;
import com.ikas.ai.server.module.condition.service.WorkConditionStepService;
import com.ikas.ai.server.module.data.model.DataMete;
import com.ikas.ai.server.module.data.service.DataMeteService;
import com.ikas.ai.utils.CollectionUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: 测试解析工况配置数据
 * @Author: qi.yilai
 * @Date: 2023/4/13 10:30
 * @Version: 1.0.0
 **/
@RestController
@RequestMapping("init/condition")
@Slf4j
public class ConditionFlowController {

    @Autowired
    private WorkConditionFlowService workConditionFlowService;

    @Autowired
    private WorkConditionStepService workConditionStepService;

    @Autowired
    private WorkConditionStepDetailService workConditionStepDetailService;

    @Autowired
    private DataMeteService dataMeteService;

    private static final List<String> U01_FILE_NAME_LIST = Lists.newArrayList("TB20(S_PC_SFC).json", "TB22(S_PC_BTB).json", "TB24(P_PC).json", "TB26(S_SR).json", "TB28(SR_G).json", "TB30(G_GC).json", "TB32(S_L).json", "TB34(S_BS).json", "TB36(P_G).json", "TB38(S_LC).json", "TB50(GC_S).json", "TB52(PC_S).json", "TB54(P_S).json", "TB56(PC_P).json", "TB58(GC_G).json", "TB60(G_SR).json", "TB62(SR_S).json", "TB70(SHUTDOWN).json", "TB71.json", "TB72.json");
    private static final List<String> U02_FILE_NAME_LIST = Lists.newArrayList("U02_TB20(S_PC_SFC).json", "U02_TB22(S_PC_BTB).json", "U02_TB24(P_PC).json", "U02_TB26(S_SR).json", "U02_TB28(SR_G).json", "U02_TB30(G_GC).json", "U02_TB32(S_L).json", "U02_TB34(S_BS).json", "U02_TB36(P_G).json", "U02_TB38(S_LC).json", "U02_TB50(GC_S).json", "U02_TB52(PC_S).json", "U02_TB54(P_S).json", "U02_TB56(PC_P).json", "U02_TB58(GC_G).json", "U02_TB60(G_SR).json", "U02_TB62(SR_S).json", "U02_TB70(SHUTDOWN).json", "U02_TB71.json", "U02_TB72.json");
    private static final List<String> U03_FILE_NAME_LIST = Lists.newArrayList("U03_TB20(S_PC_SFC).json", "U03_TB22(S_PC_BTB).json", "U03_TB24(P_PC).json", "U03_TB26(S_SR).json", "U03_TB28(SR_G).json", "U03_TB30(G_GC).json", "U03_TB32(S_L).json", "U03_TB34(S_BS).json", "U03_TB36(P_G).json", "U03_TB38(S_LC).json", "U03_TB50(GC_S).json", "U03_TB52(PC_S).json", "U03_TB54(P_S).json", "U03_TB56(PC_P).json", "U03_TB58(GC_G).json", "U03_TB60(G_SR).json", "U03_TB62(SR_S).json", "U03_TB70(SHUTDOWN).json", "U03_TB71.json", "U03_TB72.json");
    private static final List<String> U04_FILE_NAME_LIST = Lists.newArrayList("U04_TB20(S_PC_SFC).json", "U04_TB22(S_PC_BTB).json", "U04_TB24(P_PC).json", "U04_TB26(S_SR).json", "U04_TB28(SR_G).json", "U04_TB30(G_GC).json", "U04_TB32(S_L).json", "U04_TB34(S_BS).json", "U04_TB36(P_G).json", "U04_TB38(S_LC).json", "U04_TB50(GC_S).json", "U04_TB52(PC_S).json", "U04_TB54(P_S).json", "U04_TB56(PC_P).json", "U04_TB58(GC_G).json", "U04_TB60(G_SR).json", "U04_TB62(SR_S).json", "U04_TB70(SHUTDOWN).json", "U04_TB71.json", "U04_TB72.json");

    private static final String PATH = "/data/";


    @GetMapping("initCommonMeteData")
    public void initCommonMeteData() {
        deleteSpecialDataMete("TB", "U01");
        saveSpecialDateMete("TB", "U01");
        log.info("初始化工况测点表TB完毕");
    }

    @GetMapping("updateWorkConditionFlowJson")
    public JsonResult updateWorkConditionFlowJson(@RequestParam(name = "id", required = false) Long id) throws JsonProcessingException {
        workConditionFlowService.updateWorkConditionFlowJson(id);
        return JsonResult.ok();
    }

    @GetMapping(value = "saveConfig/{path}/{fileName}")
    public void saveConfig(@PathVariable("path") String path,
                           @PathVariable("fileName") String fileName) throws IOException {
        List<WorkConditionFlow> list = workConditionFlowService.list();
        Map<String, WorkConditionFlow> workConditionFlowMap = list.stream().collect(Collectors.toMap(workConditionFlow -> workConditionFlow.getMachineNo() + "_" + workConditionFlow.getWfName(), f -> f));
        InputStream inputStream = ConditionFlowController.class.getResourceAsStream("/" + path + "/" + fileName);
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String jsonData = readJSONData(bufferedReader);
        JSONObject rootJsonObject = JSONObject.parseObject(jsonData);
        JSONArray dataArray = rootJsonObject.getJSONArray("data");
        String jsonString = JSON.toJSONString(dataArray);

        InputStream inputStream1 = ConditionFlowController.class.getResourceAsStream("/" + path + "/" + fileName);
        InputStreamReader inputStreamReader1 = new InputStreamReader(inputStream1);
        BufferedReader bufferedReader1 = new BufferedReader(inputStreamReader1);
        WorkFlowMetaData workFlowMetaData = JSONWorkFlowParser.parse(readJSONData(bufferedReader1));
        List<StepMetaData> stepMetaData = workFlowMetaData.getStepMetaData();
        FlowMetaData flowMetaData = workFlowMetaData.getFlowMetaData();
        WorkConditionFlow workConditionFlow = workConditionFlowMap.get(flowMetaData.getMachineNo() + "_" + flowMetaData.getWfName());
        workConditionFlow.setConfig(jsonString);
        workConditionFlowService.updateById(workConditionFlow);
        log.info("config:{}", JSON.toJSONString(stepMetaData));
    }

    @GetMapping(value = "saveConfig/all")
    public void saveConfigAll() {
        List<WorkConditionFlow> list = workConditionFlowService.list();
        Map<String, WorkConditionFlow> workConditionFlowMap = list.stream().collect(Collectors.toMap(workConditionFlow -> workConditionFlow.getMachineNo() + "_" + workConditionFlow.getWfName(), f -> f));

        List<WorkConditionFlow> workConditionFlowList = new ArrayList<>();
        U01_FILE_NAME_LIST.forEach(item -> {
            try {
                saveConfig(item, workConditionFlowMap, workConditionFlowList);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });

        U02_FILE_NAME_LIST.forEach(item -> {
            try {
                saveConfig(item, workConditionFlowMap, workConditionFlowList);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });

        U03_FILE_NAME_LIST.forEach(item -> {
            try {
                saveConfig(item, workConditionFlowMap, workConditionFlowList);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });

        U04_FILE_NAME_LIST.forEach(item -> {
            try {
                saveConfig(item, workConditionFlowMap, workConditionFlowList);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
        workConditionFlowService.updateBatchById(workConditionFlowList);
    }

    @GetMapping(value = "saveConfig/{machineNo}")
    public void saveConfigAll(@PathVariable("machineNo") String machineNo) {
        List<WorkConditionFlow> list = workConditionFlowService.list();
        Map<String, WorkConditionFlow> workConditionFlowMap = list.stream().collect(Collectors.toMap(workConditionFlow -> workConditionFlow.getMachineNo() + "_" + workConditionFlow.getWfName(), f -> f));
        List<WorkConditionFlow> workConditionFlowList = new ArrayList<>();
        switch (machineNo) {
            case MachineAndWorkConditionConst.MACHINE_01_NO:
                U01_FILE_NAME_LIST.forEach(item -> {
                    try {
                        saveConfig(item, workConditionFlowMap, workConditionFlowList);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
                break;
            case MachineAndWorkConditionConst.MACHINE_02_NO:
                U02_FILE_NAME_LIST.forEach(item -> {
                    try {
                        saveConfig(item, workConditionFlowMap, workConditionFlowList);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
                break;
            case MachineAndWorkConditionConst.MACHINE_03_NO:
                U03_FILE_NAME_LIST.forEach(item -> {
                    try {
                        saveConfig(item, workConditionFlowMap, workConditionFlowList);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
                break;
            case MachineAndWorkConditionConst.MACHINE_04_NO:
                U04_FILE_NAME_LIST.forEach(item -> {
                    try {
                        saveConfig(item, workConditionFlowMap, workConditionFlowList);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
                break;
            default:
                throw new BusinessException("没有参数");
        }
        if (CollectionUtils.isNotEmpty(workConditionFlowList)) {
            workConditionFlowService.updateBatchById(workConditionFlowList);
        }
    }

    private void saveConfig(String item, Map<String, WorkConditionFlow> workConditionFlowMap, List<WorkConditionFlow> workConditionFlowList) throws IOException {
        InputStream inputStream = ConditionFlowController.class.getResourceAsStream(PATH + item);
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String jsonData = readJSONData(bufferedReader);
        JSONObject rootJsonObject = JSONObject.parseObject(jsonData);
        JSONArray dataArray = rootJsonObject.getJSONArray("data");
        String jsonString = JSON.toJSONString(dataArray);

        InputStream inputStream1 = ConditionFlowController.class.getResourceAsStream(PATH + item);
        InputStreamReader inputStreamReader1 = new InputStreamReader(inputStream1);
        BufferedReader bufferedReader1 = new BufferedReader(inputStreamReader1);
        WorkFlowMetaData workFlowMetaData = JSONWorkFlowParser.parse(readJSONData(bufferedReader1));
        FlowMetaData flowMetaData = workFlowMetaData.getFlowMetaData();
        WorkConditionFlow workConditionFlow = workConditionFlowMap.get(flowMetaData.getMachineNo() + "_" + flowMetaData.getWfName());
        workConditionFlow.setConfig(jsonString);
        workConditionFlow.setFlowConfigState(1);
        workConditionFlow.setInfoConfigState(1);
        workConditionFlowList.add(workConditionFlow);
    }

    @GetMapping("all")
    public void initTB20Data() throws IOException {
        clearData("U01", "TB20");
        initWorkConditionData("/data/TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB20");
        dataMeteService.initDataMeteService("U01", "TB20");
        log.info("初始化工况测点表TB20完毕");

        clearData("U01", "TB22");
        initWorkConditionData("/data/TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB22");
        dataMeteService.initDataMeteService("U01", "TB22");
        log.info("初始化工况测点表TB22完毕");

        clearData("U01", "TB24");
        initWorkConditionData("/data/TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB24");
        dataMeteService.initDataMeteService("U01", "TB24");
        log.info("初始化工况测点表TB24完毕");

//        clearData("U01", "TB26");
//        initWorkConditionData("/data/TB26(S_SR).json");
//        log.info("初始化工况模板TB26完毕");
//
//        dataMeteService.removeDataMeteByWfName("U01", "TB26");
//        dataMeteService.initDataMeteService("U01", "TB26");
//        log.info("初始化工况测点表TB26完毕");
//
//        clearData("U01", "TB28");
//        initWorkConditionData("/data/TB28(SR_G).json");
//        log.info("初始化工况模板TB28完毕");
//
//        dataMeteService.removeDataMeteByWfName("U01", "TB28");
//        dataMeteService.initDataMeteService("U01", "TB28");
//        log.info("初始化工况测点表TB28完毕");

        clearData("U01", "TB30");
        initWorkConditionData("/data/TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB30");
        dataMeteService.initDataMeteService("U01", "TB30");
        log.info("初始化工况测点表TB30完毕");

        clearData("U01", "TB32");
        initWorkConditionData("/data/TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB32");
        dataMeteService.initDataMeteService("U01", "TB32");
        log.info("初始化工况测点表TB32完毕");

        clearData("U01", "TB34");
        initWorkConditionData("/data/TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB34");
        dataMeteService.initDataMeteService("U01", "TB34");
        log.info("初始化工况测点表TB34完毕");

        clearData("U01", "TB36");
        initWorkConditionData("/data/TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB36");
        dataMeteService.initDataMeteService("U01", "TB36");
        log.info("初始化工况测点表TB36完毕");

        clearData("U01", "TB38");
        initWorkConditionData("/data/TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB38");
        dataMeteService.initDataMeteService("U01", "TB38");
        log.info("初始化工况测点表TB38完毕");

        clearData("U01", "TB50");
        initWorkConditionData("/data/TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB50");
        dataMeteService.initDataMeteService("U01", "TB50");
        log.info("初始化工况测点表TB50完毕");

        clearData("U01", "TB52");
        initWorkConditionData("/data/TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB52");
        dataMeteService.initDataMeteService("U01", "TB52");
        log.info("初始化工况测点表TB52完毕");

        clearData("U01", "TB54");
        initWorkConditionData("/data/TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB54");
        dataMeteService.initDataMeteService("U01", "TB54");
        log.info("初始化工况测点表TB54完毕");

        clearData("U01", "TB56");
        initWorkConditionData("/data/TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB56");
        dataMeteService.initDataMeteService("U01", "TB56");
        log.info("初始化工况测点表TB56完毕");

        clearData("U01", "TB58");
        initWorkConditionData("/data/TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB58");
        dataMeteService.initDataMeteService("U01", "TB58");
        log.info("初始化工况测点表TB58完毕");


//        clearData("U01", "TB60");
//        initWorkConditionData("/data/TB60(G_SR).json");
//        log.info("初始化工况模板TB60完毕");
//
//        dataMeteService.removeDataMeteByWfName("U01", "TB60");
//        dataMeteService.initDataMeteService("U01", "TB60");
//        log.info("初始化工况测点表TB60完毕");
//
//        clearData("U01", "TB62");
//        initWorkConditionData("/data/TB62(SR_S).json");
//        log.info("初始化工况模板TB62完毕");
//
//        dataMeteService.removeDataMeteByWfName("U01", "TB62");
//        dataMeteService.initDataMeteService("U01", "TB62");
//        log.info("初始化工况测点表TB62完毕");

        clearData("U01", "TB70");
        initWorkConditionData("/data/TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB70");
        dataMeteService.initDataMeteService("U01", "TB70");
        log.info("初始化工况测点表TB70完毕");

        clearData("U01", "TB71");
        initWorkConditionData("/data/TB71.json");
        log.info("初始化工况模板TB71完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB71");
        dataMeteService.initDataMeteService("U01", "TB71");
        log.info("初始化工况测点表TB71完毕");

        clearData("U01", "TB72");
        initWorkConditionData("/data/TB72.json");
        log.info("初始化工况模板TB72完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB72");
        dataMeteService.initDataMeteService("U01", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    /**
     * 初始化所有机组所有工况的模板表和dataMete表
     *
     * @throws IOException
     * @throws InterruptedException
     */
    @GetMapping("allWcAndDataMete")
    public void initAllWcAndDataMete() throws IOException, InterruptedException {
        clearData("U01", "TB20");
        initWorkConditionData("/data/TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U01", "TB22");
        initWorkConditionData("/data/TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U01", "TB24");
        initWorkConditionData("/data/TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U01", "TB26");
        initWorkConditionData("/data/TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");

        clearData("U01", "TB28");
        initWorkConditionData("/data/TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");

        clearData("U01", "TB30");
        initWorkConditionData("/data/TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        clearData("U01", "TB32");
        initWorkConditionData("/data/TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");

        clearData("U01", "TB34");
        initWorkConditionData("/data/TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");

        clearData("U01", "TB36");
        initWorkConditionData("/data/TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U01", "TB38");
        initWorkConditionData("/data/TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");

        clearData("U01", "TB50");
        initWorkConditionData("/data/TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U01", "TB52");
        initWorkConditionData("/data/TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U01", "TB54");
        initWorkConditionData("/data/TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");

        clearData("U01", "TB56");
        initWorkConditionData("/data/TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");

        clearData("U01", "TB58");
        initWorkConditionData("/data/TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");

        clearData("U01", "TB60");
        initWorkConditionData("/data/TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");

        clearData("U01", "TB62");
        initWorkConditionData("/data/TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");

        clearData("U01", "TB70");
        initWorkConditionData("/data/TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");

        clearData("U01", "TB71");
        initWorkConditionData("/data/TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U01", "TB72");
        initWorkConditionData("/data/TB72.json");
        log.info("初始化工况模板TB72完毕");

        clearData("U02", "TB20");
        initWorkConditionData("/data/U02_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");


        clearData("U02", "TB22");
        initWorkConditionData("/data/U02_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U02", "TB24");
        initWorkConditionData("/data/U02_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U02", "TB26");
        initWorkConditionData("/data/U02_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U02", "TB28");
        initWorkConditionData("/data/U02_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U02", "TB30");
        initWorkConditionData("/data/U02_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");


        clearData("U02", "TB32");
        initWorkConditionData("/data/U02_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");

        clearData("U02", "TB34");
        initWorkConditionData("/data/U02_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");

        clearData("U02", "TB36");
        initWorkConditionData("/data/U02_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U02", "TB38");
        initWorkConditionData("/data/U02_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");

        clearData("U02", "TB50");
        initWorkConditionData("/data/U02_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U02", "TB52");
        initWorkConditionData("/data/U02_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U02", "TB54");
        initWorkConditionData("/data/U02_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");

        clearData("U02", "TB56");
        initWorkConditionData("/data/U02_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");

        clearData("U02", "TB58");
        initWorkConditionData("/data/U02_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");

        clearData("U02", "TB60");
        initWorkConditionData("/data/U02_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");

        clearData("U02", "TB62");
        initWorkConditionData("/data/U02_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");

        clearData("U02", "TB70");
        initWorkConditionData("/data/U02_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");

        clearData("U02", "TB71");
        initWorkConditionData("/data/U02_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U02", "TB72");
        initWorkConditionData("/data/U02_TB72.json");
        log.info("初始化工况模板TB72完毕");

        clearData("U03", "TB20");
        initWorkConditionData("/data/U03_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U03", "TB22");
        initWorkConditionData("/data/U03_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U03", "TB24");
        initWorkConditionData("/data/U03_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U03", "TB26");
        initWorkConditionData("/data/U03_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U03", "TB28");
        initWorkConditionData("/data/U03_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U03", "TB30");
        initWorkConditionData("/data/U03_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        clearData("U03", "TB32");
        initWorkConditionData("/data/U03_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");


        clearData("U03", "TB34");
        initWorkConditionData("/data/U03_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");


        clearData("U03", "TB36");
        initWorkConditionData("/data/U03_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U03", "TB38");
        initWorkConditionData("/data/U03_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");


        clearData("U03", "TB50");
        initWorkConditionData("/data/U03_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U03", "TB52");
        initWorkConditionData("/data/U03_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U03", "TB54");
        initWorkConditionData("/data/U03_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");


        clearData("U03", "TB56");
        initWorkConditionData("/data/U03_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");


        clearData("U03", "TB58");
        initWorkConditionData("/data/U03_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");


        clearData("U03", "TB60");
        initWorkConditionData("/data/U03_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");


        clearData("U03", "TB62");
        initWorkConditionData("/data/U03_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");


        clearData("U03", "TB70");
        initWorkConditionData("/data/U03_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");


        clearData("U03", "TB71");
        initWorkConditionData("/data/U03_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U03", "TB72");
        initWorkConditionData("/data/U03_TB72.json");
        log.info("初始化工况模板TB72完毕");

        clearData("U04", "TB20");
        initWorkConditionData("/data/U04_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U04", "TB22");
        initWorkConditionData("/data/U04_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U04", "TB24");
        initWorkConditionData("/data/U04_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U04", "TB26");
        initWorkConditionData("/data/U04_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U04", "TB28");
        initWorkConditionData("/data/U04_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U04", "TB30");
        initWorkConditionData("/data/U04_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        clearData("U04", "TB32");
        initWorkConditionData("/data/U04_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");


        clearData("U04", "TB34");
        initWorkConditionData("/data/U04_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");


        clearData("U04", "TB36");
        initWorkConditionData("/data/U04_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U04", "TB38");
        initWorkConditionData("/data/U04_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");


        clearData("U04", "TB50");
        initWorkConditionData("/data/U04_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U04", "TB52");
        initWorkConditionData("/data/U04_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U04", "TB54");
        initWorkConditionData("/data/U04_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");


        clearData("U04", "TB56");
        initWorkConditionData("/data/U04_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");


        clearData("U04", "TB58");
        initWorkConditionData("/data/U04_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");


        clearData("U04", "TB60");
        initWorkConditionData("/data/U04_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");


        clearData("U04", "TB62");
        initWorkConditionData("/data/U04_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");


        clearData("U04", "TB70");
        initWorkConditionData("/data/U04_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");


        clearData("U04", "TB71");
        initWorkConditionData("/data/U04_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U04", "TB72");
        initWorkConditionData("/data/U04_TB72.json");
        log.info("初始化工况模板TB72完毕");

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }

        dataMeteService.removeDataMeteByWfName("U01", "TB20");
        dataMeteService.initDataMeteService("U01", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB22");
        dataMeteService.initDataMeteService("U01", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB24");
        dataMeteService.initDataMeteService("U01", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB26");
        dataMeteService.initDataMeteService("U01", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB28");
        dataMeteService.initDataMeteService("U01", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB30");
        dataMeteService.initDataMeteService("U01", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB32");
        dataMeteService.initDataMeteService("U01", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB34");
        dataMeteService.initDataMeteService("U01", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB36");
        dataMeteService.initDataMeteService("U01", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB38");
        dataMeteService.initDataMeteService("U01", "TB38");
        log.info("初始化工况测点表TB38完毕");


        dataMeteService.removeDataMeteByWfName("U01", "TB50");
        dataMeteService.initDataMeteService("U01", "TB50");
        log.info("初始化工况测点表TB50完毕");


        dataMeteService.removeDataMeteByWfName("U01", "TB52");
        dataMeteService.initDataMeteService("U01", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB54");
        dataMeteService.initDataMeteService("U01", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB56");
        dataMeteService.initDataMeteService("U01", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB58");
        dataMeteService.initDataMeteService("U01", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB60");
        dataMeteService.initDataMeteService("U01", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB62");
        dataMeteService.initDataMeteService("U01", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB70");
        dataMeteService.initDataMeteService("U01", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB71");
        dataMeteService.initDataMeteService("U01", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB72");
        dataMeteService.initDataMeteService("U01", "TB72");
        log.info("初始化工况测点表TB72完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB20");
        dataMeteService.initDataMeteService("U02", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB22");
        dataMeteService.initDataMeteService("U02", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB24");
        dataMeteService.initDataMeteService("U02", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB26");
        dataMeteService.initDataMeteService("U02", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB28");
        dataMeteService.initDataMeteService("U02", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB30");
        dataMeteService.initDataMeteService("U02", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB32");
        dataMeteService.initDataMeteService("U02", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB34");
        dataMeteService.initDataMeteService("U02", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB36");
        dataMeteService.initDataMeteService("U02", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB38");
        dataMeteService.initDataMeteService("U02", "TB38");
        log.info("初始化工况测点表TB38完毕");


        dataMeteService.removeDataMeteByWfName("U02", "TB50");
        dataMeteService.initDataMeteService("U02", "TB50");
        log.info("初始化工况测点表TB50完毕");


        dataMeteService.removeDataMeteByWfName("U02", "TB52");
        dataMeteService.initDataMeteService("U02", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB54");
        dataMeteService.initDataMeteService("U02", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB56");
        dataMeteService.initDataMeteService("U02", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB58");
        dataMeteService.initDataMeteService("U02", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB60");
        dataMeteService.initDataMeteService("U02", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB62");
        dataMeteService.initDataMeteService("U02", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB70");
        dataMeteService.initDataMeteService("U02", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB71");
        dataMeteService.initDataMeteService("U02", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB72");
        dataMeteService.initDataMeteService("U02", "TB72");
        log.info("初始化工况测点表TB72完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB20");
        dataMeteService.initDataMeteService("U03", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB22");
        dataMeteService.initDataMeteService("U03", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB24");
        dataMeteService.initDataMeteService("U03", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB26");
        dataMeteService.initDataMeteService("U03", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB28");
        dataMeteService.initDataMeteService("U03", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB30");
        dataMeteService.initDataMeteService("U03", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB32");
        dataMeteService.initDataMeteService("U03", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB34");
        dataMeteService.initDataMeteService("U03", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB36");
        dataMeteService.initDataMeteService("U03", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB38");
        dataMeteService.initDataMeteService("U03", "TB38");
        log.info("初始化工况测点表TB38完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB50");
        dataMeteService.initDataMeteService("U03", "TB50");
        log.info("初始化工况测点表TB50完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB52");
        dataMeteService.initDataMeteService("U03", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB54");
        dataMeteService.initDataMeteService("U03", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB56");
        dataMeteService.initDataMeteService("U03", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB58");
        dataMeteService.initDataMeteService("U03", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB60");
        dataMeteService.initDataMeteService("U03", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB62");
        dataMeteService.initDataMeteService("U03", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB70");
        dataMeteService.initDataMeteService("U03", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB71");
        dataMeteService.initDataMeteService("U03", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB72");
        dataMeteService.initDataMeteService("U03", "TB72");
        log.info("初始化工况测点表TB72完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB20");
        dataMeteService.initDataMeteService("U04", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB22");
        dataMeteService.initDataMeteService("U04", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB24");
        dataMeteService.initDataMeteService("U04", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB26");
        dataMeteService.initDataMeteService("U04", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB28");
        dataMeteService.initDataMeteService("U04", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB30");
        dataMeteService.initDataMeteService("U04", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB32");
        dataMeteService.initDataMeteService("U04", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB34");
        dataMeteService.initDataMeteService("U04", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB36");
        dataMeteService.initDataMeteService("U04", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB38");
        dataMeteService.initDataMeteService("U04", "TB38");
        log.info("初始化工况测点表TB38完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB50");
        dataMeteService.initDataMeteService("U04", "TB50");
        log.info("初始化工况测点表TB50完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB52");
        dataMeteService.initDataMeteService("U04", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB54");
        dataMeteService.initDataMeteService("U04", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB56");
        dataMeteService.initDataMeteService("U04", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB58");
        dataMeteService.initDataMeteService("U04", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB60");
        dataMeteService.initDataMeteService("U04", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB62");
        dataMeteService.initDataMeteService("U04", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB70");
        dataMeteService.initDataMeteService("U04", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB71");
        dataMeteService.initDataMeteService("U04", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB72");
        dataMeteService.initDataMeteService("U04", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    /**
     * 初始化U01所有工况的模板表
     *
     * @throws IOException
     * @throws InterruptedException
     */
    @GetMapping("U01/wc")
    public void initU01Data() throws IOException {
        clearData("U01", "TB20");
        initWorkConditionData("/data/TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U01", "TB22");
        initWorkConditionData("/data/TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U01", "TB24");
        initWorkConditionData("/data/TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U01", "TB26");
        initWorkConditionData("/data/TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U01", "TB28");
        initWorkConditionData("/data/TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U01", "TB30");
        initWorkConditionData("/data/TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");


        clearData("U01", "TB32");
        initWorkConditionData("/data/TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");

        clearData("U01", "TB34");
        initWorkConditionData("/data/TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");

        clearData("U01", "TB36");
        initWorkConditionData("/data/TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U01", "TB38");
        initWorkConditionData("/data/TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");

        clearData("U01", "TB50");
        initWorkConditionData("/data/TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U01", "TB52");
        initWorkConditionData("/data/TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U01", "TB54");
        initWorkConditionData("/data/TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");

        clearData("U01", "TB56");
        initWorkConditionData("/data/TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");

        clearData("U01", "TB58");
        initWorkConditionData("/data/TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");

        clearData("U01", "TB60");
        initWorkConditionData("/data/TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");

        clearData("U01", "TB62");
        initWorkConditionData("/data/TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");

        clearData("U01", "TB70");
        initWorkConditionData("/data/TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");

        clearData("U01", "TB71");
        initWorkConditionData("/data/TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U01", "TB72");
        initWorkConditionData("/data/TB72.json");
        log.info("初始化工况模板TB72完毕");
    }

    /**
     * 初始化U01所有工况的dataMete表
     *
     * @throws IOException
     * @throws InterruptedException
     */
    @GetMapping("U01/data")
    public void initU01DataMete() {

        dataMeteService.removeDataMeteByWfName("U01", "TB20");
        dataMeteService.initDataMeteService("U01", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB22");
        dataMeteService.initDataMeteService("U01", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB24");
        dataMeteService.initDataMeteService("U01", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB26");
        dataMeteService.initDataMeteService("U01", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB28");
        dataMeteService.initDataMeteService("U01", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB30");
        dataMeteService.initDataMeteService("U01", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB32");
        dataMeteService.initDataMeteService("U01", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB34");
        dataMeteService.initDataMeteService("U01", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB36");
        dataMeteService.initDataMeteService("U01", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB38");
        dataMeteService.initDataMeteService("U01", "TB38");
        log.info("初始化工况测点表TB38完毕");


        dataMeteService.removeDataMeteByWfName("U01", "TB50");
        dataMeteService.initDataMeteService("U01", "TB50");
        log.info("初始化工况测点表TB50完毕");


        dataMeteService.removeDataMeteByWfName("U01", "TB52");
        dataMeteService.initDataMeteService("U01", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB54");
        dataMeteService.initDataMeteService("U01", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB56");
        dataMeteService.initDataMeteService("U01", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB58");
        dataMeteService.initDataMeteService("U01", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB60");
        dataMeteService.initDataMeteService("U01", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB62");
        dataMeteService.initDataMeteService("U01", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB70");
        dataMeteService.initDataMeteService("U01", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB71");
        dataMeteService.initDataMeteService("U01", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U01", "TB72");
        dataMeteService.initDataMeteService("U01", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    @GetMapping("U02/wc")
    public void initU02Data() throws IOException {
        clearData("U02", "TB20");
        initWorkConditionData("/data/U02_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");


        clearData("U02", "TB22");
        initWorkConditionData("/data/U02_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U02", "TB24");
        initWorkConditionData("/data/U02_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U02", "TB26");
        initWorkConditionData("/data/U02_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U02", "TB28");
        initWorkConditionData("/data/U02_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U02", "TB30");
        initWorkConditionData("/data/U02_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");


        clearData("U02", "TB32");
        initWorkConditionData("/data/U02_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");

        clearData("U02", "TB34");
        initWorkConditionData("/data/U02_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");

        clearData("U02", "TB36");
        initWorkConditionData("/data/U02_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U02", "TB38");
        initWorkConditionData("/data/U02_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");

        clearData("U02", "TB50");
        initWorkConditionData("/data/U02_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U02", "TB52");
        initWorkConditionData("/data/U02_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U02", "TB54");
        initWorkConditionData("/data/U02_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");

        clearData("U02", "TB56");
        initWorkConditionData("/data/U02_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");

        clearData("U02", "TB58");
        initWorkConditionData("/data/U02_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");


        clearData("U02", "TB60");
        initWorkConditionData("/data/U02_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");

        clearData("U02", "TB62");
        initWorkConditionData("/data/U02_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");

        clearData("U02", "TB70");
        initWorkConditionData("/data/U02_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");

        clearData("U02", "TB71");
        initWorkConditionData("/data/U02_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U02", "TB72");
        initWorkConditionData("/data/U02_TB72.json");
        log.info("初始化工况模板TB72完毕");
    }

    @GetMapping("U02/data")
    public void initU02DataMete() {

        dataMeteService.removeDataMeteByWfName("U02", "TB20");
        dataMeteService.initDataMeteService("U02", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB22");
        dataMeteService.initDataMeteService("U02", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB24");
        dataMeteService.initDataMeteService("U02", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB26");
        dataMeteService.initDataMeteService("U02", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB28");
        dataMeteService.initDataMeteService("U02", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB30");
        dataMeteService.initDataMeteService("U02", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB32");
        dataMeteService.initDataMeteService("U02", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB34");
        dataMeteService.initDataMeteService("U02", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB36");
        dataMeteService.initDataMeteService("U02", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB38");
        dataMeteService.initDataMeteService("U02", "TB38");
        log.info("初始化工况测点表TB38完毕");


        dataMeteService.removeDataMeteByWfName("U02", "TB50");
        dataMeteService.initDataMeteService("U02", "TB50");
        log.info("初始化工况测点表TB50完毕");


        dataMeteService.removeDataMeteByWfName("U02", "TB52");
        dataMeteService.initDataMeteService("U02", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB54");
        dataMeteService.initDataMeteService("U02", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB56");
        dataMeteService.initDataMeteService("U02", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB58");
        dataMeteService.initDataMeteService("U02", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB60");
        dataMeteService.initDataMeteService("U02", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB62");
        dataMeteService.initDataMeteService("U02", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB70");
        dataMeteService.initDataMeteService("U02", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB71");
        dataMeteService.initDataMeteService("U02", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U02", "TB72");
        dataMeteService.initDataMeteService("U02", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    @GetMapping("U03/wc")
    public void initU03Data() throws IOException {
        clearData("U03", "TB20");
        initWorkConditionData("/data/U03_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U03", "TB22");
        initWorkConditionData("/data/U03_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U03", "TB24");
        initWorkConditionData("/data/U03_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U03", "TB26");
        initWorkConditionData("/data/U03_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U03", "TB28");
        initWorkConditionData("/data/U03_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U03", "TB30");
        initWorkConditionData("/data/U03_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        clearData("U03", "TB32");
        initWorkConditionData("/data/U03_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");


        clearData("U03", "TB34");
        initWorkConditionData("/data/U03_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");


        clearData("U03", "TB36");
        initWorkConditionData("/data/U03_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U03", "TB38");
        initWorkConditionData("/data/U03_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");


        clearData("U03", "TB50");
        initWorkConditionData("/data/U03_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U03", "TB52");
        initWorkConditionData("/data/U03_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U03", "TB54");
        initWorkConditionData("/data/U03_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");


        clearData("U03", "TB56");
        initWorkConditionData("/data/U03_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");


        clearData("U03", "TB58");
        initWorkConditionData("/data/U03_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");


        clearData("U03", "TB60");
        initWorkConditionData("/data/U03_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");


        clearData("U03", "TB62");
        initWorkConditionData("/data/U03_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");


        clearData("U03", "TB70");
        initWorkConditionData("/data/U03_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");


        clearData("U03", "TB71");
        initWorkConditionData("/data/U03_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U03", "TB72");
        initWorkConditionData("/data/U03_TB72.json");
        log.info("初始化工况模板TB72完毕");

    }

    @GetMapping("U03/data")
    public void initU03DataMete() {

        dataMeteService.removeDataMeteByWfName("U03", "TB20");
        dataMeteService.initDataMeteService("U03", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB22");
        dataMeteService.initDataMeteService("U03", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB24");
        dataMeteService.initDataMeteService("U03", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB26");
        dataMeteService.initDataMeteService("U03", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB28");
        dataMeteService.initDataMeteService("U03", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB30");
        dataMeteService.initDataMeteService("U03", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB32");
        dataMeteService.initDataMeteService("U03", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB34");
        dataMeteService.initDataMeteService("U03", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB36");
        dataMeteService.initDataMeteService("U03", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB38");
        dataMeteService.initDataMeteService("U03", "TB38");
        log.info("初始化工况测点表TB38完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB50");
        dataMeteService.initDataMeteService("U03", "TB50");
        log.info("初始化工况测点表TB50完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB52");
        dataMeteService.initDataMeteService("U03", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB54");
        dataMeteService.initDataMeteService("U03", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB56");
        dataMeteService.initDataMeteService("U03", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB58");
        dataMeteService.initDataMeteService("U03", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB60");
        dataMeteService.initDataMeteService("U03", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB62");
        dataMeteService.initDataMeteService("U03", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB70");
        dataMeteService.initDataMeteService("U03", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB71");
        dataMeteService.initDataMeteService("U03", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U03", "TB72");
        dataMeteService.initDataMeteService("U03", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    @GetMapping("U04/wc")
    public void initU04Data() throws IOException {
        clearData("U04", "TB20");
        initWorkConditionData("/data/U04_TB20(S_PC_SFC).json");
        log.info("初始化工况模板TB20完毕");

        clearData("U04", "TB22");
        initWorkConditionData("/data/U04_TB22(S_PC_BTB).json");
        log.info("初始化工况模板TB22完毕");

        clearData("U04", "TB24");
        initWorkConditionData("/data/U04_TB24(P_PC).json");
        log.info("初始化工况模板TB24完毕");

        clearData("U04", "TB26");
        initWorkConditionData("/data/U04_TB26(S_SR).json");
        log.info("初始化工况模板TB26完毕");


        clearData("U04", "TB28");
        initWorkConditionData("/data/U04_TB28(SR_G).json");
        log.info("初始化工况模板TB28完毕");


        clearData("U04", "TB30");
        initWorkConditionData("/data/U04_TB30(G_GC).json");
        log.info("初始化工况模板TB30完毕");

        clearData("U04", "TB32");
        initWorkConditionData("/data/U04_TB32(S_L).json");
        log.info("初始化工况模板TB32完毕");


        clearData("U04", "TB34");
        initWorkConditionData("/data/U04_TB34(S_BS).json");
        log.info("初始化工况模板TB34完毕");


        clearData("U04", "TB36");
        initWorkConditionData("/data/U04_TB36(P_G).json");
        log.info("初始化工况模板TB36完毕");

        clearData("U04", "TB38");
        initWorkConditionData("/data/U04_TB38(S_LC).json");
        log.info("初始化工况模板TB38完毕");


        clearData("U04", "TB50");
        initWorkConditionData("/data/U04_TB50(GC_S).json");
        log.info("初始化工况模板TB50完毕");

        clearData("U04", "TB52");
        initWorkConditionData("/data/U04_TB52(PC_S).json");
        log.info("初始化工况模板TB52完毕");

        clearData("U04", "TB54");
        initWorkConditionData("/data/U04_TB54(P_S).json");
        log.info("初始化工况模板TB54完毕");


        clearData("U04", "TB56");
        initWorkConditionData("/data/U04_TB56(PC_P).json");
        log.info("初始化工况模板TB56完毕");


        clearData("U04", "TB58");
        initWorkConditionData("/data/U04_TB58(GC_G).json");
        log.info("初始化工况模板TB58完毕");


        clearData("U04", "TB60");
        initWorkConditionData("/data/U04_TB60(G_SR).json");
        log.info("初始化工况模板TB60完毕");


        clearData("U04", "TB62");
        initWorkConditionData("/data/U04_TB62(SR_S).json");
        log.info("初始化工况模板TB62完毕");


        clearData("U04", "TB70");
        initWorkConditionData("/data/U04_TB70(SHUTDOWN).json");
        log.info("初始化工况模板TB70完毕");


        clearData("U04", "TB71");
        initWorkConditionData("/data/U04_TB71.json");
        log.info("初始化工况模板TB71完毕");

        clearData("U04", "TB72");
        initWorkConditionData("/data/U04_TB72.json");
        log.info("初始化工况模板TB72完毕");

    }

    @GetMapping("U04/data")
    public void initU04DataMete() {

        dataMeteService.removeDataMeteByWfName("U04", "TB20");
        dataMeteService.initDataMeteService("U04", "TB20");
        log.info("初始化工况测点表TB20完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB22");
        dataMeteService.initDataMeteService("U04", "TB22");
        log.info("初始化工况测点表TB22完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB24");
        dataMeteService.initDataMeteService("U04", "TB24");
        log.info("初始化工况测点表TB24完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB26");
        dataMeteService.initDataMeteService("U04", "TB26");
        log.info("初始化工况测点表TB26完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB28");
        dataMeteService.initDataMeteService("U04", "TB28");
        log.info("初始化工况测点表TB28完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB30");
        dataMeteService.initDataMeteService("U04", "TB30");
        log.info("初始化工况测点表TB30完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB32");
        dataMeteService.initDataMeteService("U04", "TB32");
        log.info("初始化工况测点表TB32完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB34");
        dataMeteService.initDataMeteService("U04", "TB34");
        log.info("初始化工况测点表TB34完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB36");
        dataMeteService.initDataMeteService("U04", "TB36");
        log.info("初始化工况测点表TB36完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB38");
        dataMeteService.initDataMeteService("U04", "TB38");
        log.info("初始化工况测点表TB38完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB50");
        dataMeteService.initDataMeteService("U04", "TB50");
        log.info("初始化工况测点表TB50完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB52");
        dataMeteService.initDataMeteService("U04", "TB52");
        log.info("初始化工况测点表TB52完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB54");
        dataMeteService.initDataMeteService("U04", "TB54");
        log.info("初始化工况测点表TB54完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB56");
        dataMeteService.initDataMeteService("U04", "TB56");
        log.info("初始化工况测点表TB56完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB58");
        dataMeteService.initDataMeteService("U04", "TB58");
        log.info("初始化工况测点表TB58完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB60");
        dataMeteService.initDataMeteService("U04", "TB60");
        log.info("初始化工况测点表TB60完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB62");
        dataMeteService.initDataMeteService("U04", "TB62");
        log.info("初始化工况测点表TB62完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB70");
        dataMeteService.initDataMeteService("U04", "TB70");
        log.info("初始化工况测点表TB70完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB71");
        dataMeteService.initDataMeteService("U04", "TB71");
        log.info("初始化工况测点表TB71完毕");

        dataMeteService.removeDataMeteByWfName("U04", "TB72");
        dataMeteService.initDataMeteService("U04", "TB72");
        log.info("初始化工况测点表TB72完毕");
    }

    private void clearData(String machineNo, String wfName) {
        WorkConditionFlow workConditionFlow = workConditionFlowService.removeWorkConditionFlow(machineNo, wfName);
        if (Objects.nonNull(workConditionFlow)) {
            workConditionStepService.removeWorkConditionStepByWfId(workConditionFlow.getId());
            workConditionStepDetailService.removeWOrkConditionStepDetailByWfId(workConditionFlow.getId());
        }
    }

    /**
     * 初始化配置数据
     */
    private void initWorkConditionData(String fileName) throws IOException {
        InputStream inputStream = ConditionFlowController.class.getResourceAsStream(fileName);
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        WorkFlowMetaData workFlowMetaData = JSONWorkFlowParser.parse(readJSONData(bufferedReader));

        //data--->config
        InputStream inputStreamNew = ConditionFlowController.class.getResourceAsStream(fileName);
        InputStreamReader inputStreamReaderNew = new InputStreamReader(inputStreamNew);
        BufferedReader bufferedReaderNew = new BufferedReader(inputStreamReaderNew);
        String jsonData = readJSONData(bufferedReaderNew);
        JSONObject rootJsonObject = JSONObject.parseObject(jsonData);
        JSONArray dataArray = rootJsonObject.getJSONArray("data");
        String config = JSON.toJSONString(dataArray);

        FlowMetaData flowMetaData = workFlowMetaData.getFlowMetaData();
        WorkConditionFlow workConditionFlow = createWorkConditionFlow(flowMetaData);
        workConditionFlow.setConfig(config);
        workConditionFlow.setFlowConfigState(1);
        workConditionFlow.setInfoConfigState(1);
        workConditionFlowService.save(workConditionFlow);
        List<StepMetaData> stepMetas = workFlowMetaData.getStepMetaData();

        List<WorkConditionStep> allSteps = Lists.newArrayList();
        List<WorkConditionStepDetail> details = Lists.newArrayList();

        stepMetas.forEach(stepMetaData -> {
            WorkConditionStep workConditionStep = createWorkConditionStep(workConditionFlow, stepMetaData);
            workConditionStepService.save(workConditionStep);
            allSteps.add(workConditionStep);
            List<StepDetailMetaData> list = stepMetaData.getDetails();
            Map<StepDetailMetaData, WorkConditionStepDetail> detailMap = createWorkConditionStepDetail(workConditionStep, list);
            details.addAll(detailMap.values());
            updateWorkConditionStepDetail(detailMap, list);
        });
        // 更新groupStepId
        updateGroupStepId(allSteps, details);
    }

    /**
     * 更新groupStepId
     *
     * @param allSteps
     * @param details
     */
    private void updateGroupStepId(List<WorkConditionStep> allSteps, List<WorkConditionStepDetail> details) {
        Map<String, Long> key2IdMap = allSteps.stream().collect(Collectors.toMap(WorkConditionStep::getStepName, WorkConditionStep::getId));
        List<WorkConditionStepDetail> updates = Lists.newArrayList();

        details.stream().forEach(workConditionStepDetail -> {
            String toStep = workConditionStepDetail.getGroupStep();
            if (StringUtils.isNotEmpty(toStep) && !"step0".equals(toStep)) {
                Long stepId = key2IdMap.get(toStep);
                if (Objects.nonNull(stepId)) {
                    workConditionStepDetail.setGroupStepId(stepId);
                    updates.add(workConditionStepDetail);
                }
            }
        });
        if (!CollectionUtil.isEmpty(updates)) {
            workConditionStepDetailService.updateBatchById(updates);
        }
    }

    /**
     * 创建工况详情
     *
     * @param workConditionStep
     * @param list
     * @return
     */
    private Map<StepDetailMetaData, WorkConditionStepDetail> createWorkConditionStepDetail(WorkConditionStep workConditionStep, List<StepDetailMetaData> list) {
        Map<StepDetailMetaData, WorkConditionStepDetail> meta2DetailMap = Maps.newIdentityHashMap();
        List<WorkConditionStepDetail> details = Lists.newArrayList();
        list.stream().forEach(stepDetailMetaData -> {
            WorkConditionStepDetail workConditionStepDetail = new WorkConditionStepDetail();
            // 1= 测点 4=忽略项
            if (stepDetailMetaData.getLabelType() == 1 || stepDetailMetaData.getLabelType() == 4) {
                workConditionStepDetail.setWfId(workConditionStep.getWfId());
                workConditionStepDetail.setStepId(workConditionStep.getId());
                if (StringUtils.isNotBlank(stepDetailMetaData.getMeteName())) {
                    workConditionStepDetail.setMeteName(stepDetailMetaData.getMeteName());
                } else {
                    workConditionStepDetail.setMeteName(stepDetailMetaData.getLabel());
                }
                workConditionStepDetail.setMeteCode(stepDetailMetaData.getMeteCode());
                workConditionStepDetail.setValidMeteValue(stepDetailMetaData.getValidMeteValue());
                workConditionStepDetail.setType(stepDetailMetaData.getType());
                workConditionStepDetail.setLeaf(stepDetailMetaData.isLeaf());
                workConditionStepDetail.setSubLogicalOperator(stepDetailMetaData.getSubLogicalOperator());
                workConditionStepDetail.setSort(stepDetailMetaData.getSort());
                workConditionStepDetail.setGroupNo(stepDetailMetaData.getGroupNo());
                workConditionStepDetail.setGroupStep(stepDetailMetaData.getGroupToStep());
                workConditionStepDetail.setLabelType(stepDetailMetaData.getLabelType());
                workConditionStepDetail.setPMeteCode(stepDetailMetaData.getPMeteCodes());
                workConditionStepDetail.setUpdatePolicy(1);
                workConditionStepDetail.setEarlyCache("step0".equals(workConditionStep.getStepName()) ? 1 : 0);
                if (!stepDetailMetaData.isLeaf()) {
                    meta2DetailMap.putAll(createWorkConditionStepDetail(workConditionStep, stepDetailMetaData.getSubDetails()));
                }
                meta2DetailMap.put(stepDetailMetaData, workConditionStepDetail);
            } else if (stepDetailMetaData.getLabelType() == 2 || stepDetailMetaData.getLabelType() == 3) {
                // 2=无测点,仅描述,3=无测点,虚线框
                workConditionStepDetail.setWfId(workConditionStep.getWfId());
                workConditionStepDetail.setStepId(workConditionStep.getId());
                workConditionStepDetail.setType(stepDetailMetaData.getType());
                workConditionStepDetail.setLabelType(stepDetailMetaData.getLabelType());
                workConditionStepDetail.setLabel(stepDetailMetaData.getLabel());
                workConditionStepDetail.setGroupNo(stepDetailMetaData.getGroupNo());
                workConditionStepDetail.setGroupStep(stepDetailMetaData.getGroupToStep());
                workConditionStepDetail.setUpdatePolicy(2);
                workConditionStepDetail.setEarlyCache("step0".equals(workConditionStep.getStepName()) ? 1 : 0);
                meta2DetailMap.put(stepDetailMetaData, workConditionStepDetail);
            }
            details.add(workConditionStepDetail);

        });
        workConditionStepDetailService.saveBatch(details);
        return meta2DetailMap;
    }

    /**
     * 更新工况subIds和pDetailId详情
     *
     * @param meta2DetailMap
     * @param list
     */
    private void updateWorkConditionStepDetail(Map<StepDetailMetaData, WorkConditionStepDetail> meta2DetailMap, List<StepDetailMetaData> list) {

        List<WorkConditionStepDetail> details = Lists.newArrayList();
        list.stream().forEach(stepDetailMetaData -> {
            if (!CollectionUtil.isEmpty(stepDetailMetaData.getSubDetails())) {
                WorkConditionStepDetail workConditionStepDetail = meta2DetailMap.get(stepDetailMetaData);
                List<StepDetailMetaData> subs = stepDetailMetaData.getSubDetails();
                List<Long> subIds = subs.stream().map(sub -> {
                    WorkConditionStepDetail subWorkConditionStepDetail = meta2DetailMap.get(sub);
                    return subWorkConditionStepDetail.getId();
                }).collect(Collectors.toList());
                workConditionStepDetail.setSubDetailIds(subIds);
                if (!details.contains(workConditionStepDetail)) {
                    details.add(workConditionStepDetail);
                }

                subs.stream().forEach(sub -> {
                    WorkConditionStepDetail subWorkConditionStepDetail = meta2DetailMap.get(sub);
                    subWorkConditionStepDetail.setPDetailId(workConditionStepDetail.getId());
                    if (!details.contains(subWorkConditionStepDetail)) {
                        details.add(subWorkConditionStepDetail);
                    }
                });
                updateWorkConditionStepDetail(meta2DetailMap, subs);
            }
        });
        if (!details.isEmpty()) {
            workConditionStepDetailService.updateBatchById(details);
        }
    }

    /**
     * 创建工况流程步骤
     *
     * @param stepMetaData
     * @return
     */
    private WorkConditionStep createWorkConditionStep(WorkConditionFlow workConditionFlow, StepMetaData stepMetaData) {
        WorkConditionStep workConditionStep = new WorkConditionStep();
        workConditionStep.setWfId(workConditionFlow.getId());
        workConditionStep.setWfName(workConditionFlow.getWfName());
        workConditionStep.setStepName(stepMetaData.getStep());
        workConditionStep.setStep(Integer.parseInt(stepMetaData.getStep().substring(4)));
        workConditionStep.setMeteName(stepMetaData.getMeteName());
        workConditionStep.setMeteCode(stepMetaData.getMeteCode());
        workConditionStep.setValidMeteValue(stepMetaData.getValidMeteValue());
        workConditionStep.setDefaultDelay(stepMetaData.getDefaultDelay());
        workConditionStep.setSort(stepMetaData.getSort());
        workConditionStep.setType(stepMetaData.getType());
        workConditionStep.setCreateTime(new Date());
        return workConditionStep;
    }

    /**
     * 创建工况流程
     *
     * @param flowMetaData
     * @return
     */
    private WorkConditionFlow createWorkConditionFlow(FlowMetaData flowMetaData) {
        WorkConditionFlow workConditionFlow = new WorkConditionFlow();
        workConditionFlow.setMachineId(flowMetaData.getMachineId().longValue());
        workConditionFlow.setMachineNo(flowMetaData.getMachineNo());
        workConditionFlow.setWfName(flowMetaData.getWfName());
        workConditionFlow.setCurrWc(flowMetaData.getCurrWc());
        workConditionFlow.setNextWc(flowMetaData.getNextWc());
        workConditionFlow.setMeteName(flowMetaData.getMeteName());
        workConditionFlow.setMeteCode(flowMetaData.getMeteCode());
        workConditionFlow.setValidMeteValue(flowMetaData.getValidMeteValue());
        workConditionFlow.setStartMete(flowMetaData.getStartMete());
        workConditionFlow.setStartMeteName(flowMetaData.getStartMeteName());
        workConditionFlow.setEndMete(flowMetaData.getEndMete());
        workConditionFlow.setEndMeteName(flowMetaData.getEndMeteName());
        workConditionFlow.setDesc("");
        workConditionFlow.setCreateTime(new Date());
        workConditionFlow.setWfDesc(flowMetaData.getWfName());
        return workConditionFlow;
    }

    private String readJSONData(BufferedReader bufferedReader) throws IOException {
        StringBuffer sb = new StringBuffer();
        String line;
        while (StringUtils.isNotEmpty(line = bufferedReader.readLine())) {
            sb.append(line);
        }
        return sb.toString();
    }


    /**
     * 保存特殊测点
     */
    private void saveSpecialDateMete(String wfName, String machineNo) {
        List<DataMete> result = new ArrayList<>();
        DataMete mete = new DataMete();
        mete.setMeteId(75764L);
        mete.setMeteCode("1CRK00_MODE_DZ_PC");
        mete.setMeteName("机组在PC工况");
        mete.setMachineNo(machineNo);
        mete.setType(1);
        mete.setWfName(wfName);
        mete.setStep(0);
        mete.setValidMeteValue("1");
        result.add(mete);

        DataMete mete2 = new DataMete();
        mete2.setMeteId(75771L);
        mete2.setMeteCode("1CRK00_MODE_DZ_P");
        mete2.setMeteName("机组在P工况");
        mete2.setMachineNo(machineNo);
        mete2.setType(1);
        mete2.setWfName(wfName);
        mete2.setStep(0);
        mete2.setValidMeteValue("1");
        result.add(mete2);

        DataMete mete3 = new DataMete();
        mete3.setMeteId(75772L);
        mete3.setMeteCode("1CRK00_MODE_DZ_STL");
        mete3.setMeteName("机组在稳态");
        mete3.setMachineNo(machineNo);
        mete3.setType(1);
        mete3.setWfName(wfName);
        mete3.setStep(0);
        mete3.setValidMeteValue("1");
        result.add(mete3);

        DataMete mete4 = new DataMete();
        mete4.setMeteId(75778L);
        mete4.setMeteCode("1CRK00_MODE_DZ_SR");
        mete4.setMeteName("机组在SR工况");
        mete4.setMachineNo(machineNo);
        mete4.setType(1);
        mete4.setWfName(wfName);
        mete4.setStep(0);
        mete4.setValidMeteValue("1");
        result.add(mete4);


        DataMete mete5 = new DataMete();
        mete5.setMeteId(75782L);
        mete5.setMeteCode("1CRK00_MODE_DZ_G");
        mete5.setMeteName("机组在G工况");
        mete5.setMachineNo(machineNo);
        mete5.setType(1);
        mete5.setWfName(wfName);
        mete5.setStep(0);
        mete5.setValidMeteValue("1");
        result.add(mete5);

        DataMete mete6 = new DataMete();
        mete6.setMeteId(75787L);
        mete6.setMeteCode("1CRK00_MODE_DZ_GC");
        mete6.setMeteName("机组在GC工况");
        mete6.setMachineNo(machineNo);
        mete6.setType(1);
        mete6.setWfName(wfName);
        mete6.setStep(0);
        mete6.setValidMeteValue("1");
        result.add(mete6);


        DataMete mete7 = new DataMete();
        mete7.setMeteId(75792L);
        mete7.setMeteCode("1CRK00_MODE_DZ_BS");
        mete7.setMeteName("机组在BS工况");
        mete7.setMachineNo(machineNo);
        mete7.setType(1);
        mete7.setWfName(wfName);
        mete7.setStep(0);
        mete7.setValidMeteValue("1");
        result.add(mete7);

        DataMete mete8 = new DataMete();
        mete8.setMeteId(75795L);
        mete8.setMeteCode("1CRK00_MODE_DZ_LC");
        mete8.setMeteName("机组在LC工况");
        mete8.setMachineNo(machineNo);
        mete8.setType(1);
        mete8.setWfName(wfName);
        mete8.setStep(0);
        mete8.setValidMeteValue("1");
        result.add(mete8);

        dataMeteService.saveBatch(result);
    }

    private void deleteSpecialDataMete(String wfName, String machineNo) {
        LambdaQueryWrapper<DataMete> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DataMete::getWfName, wfName).eq(DataMete::getMachineNo, machineNo);
        dataMeteService.remove(queryWrapper);
    }
}
